10 Stochastic SimulationΒΆ
[13]:
from src.plot import plot_simulated_stoc_path_full2_singapore2
plot_simulated_stoc_path_full2_singapore2("RD_Plot", "","Percentage (%)", [0,8])
[14]:
plot_simulated_stoc_path_full2_singapore("e", """""","Gigatonne", [6,20])
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
c:\Users\33678\ClimateSocialPolicy\sec10_stochastic_simulation_singapore.ipynb Cell 3 in <cell line: 1>()
----> <a href='vscode-notebook-cell:/c%3A/Users/33678/ClimateSocialPolicy/sec10_stochastic_simulation_singapore.ipynb#W2sZmlsZQ%3D%3D?line=0'>1</a> plot_simulated_stoc_path_full2_singapore("e", """""","Gigatonne", [6,20])
NameError: name 'plot_simulated_stoc_path_full2_singapore' is not defined
[ ]:
plot_simulated_stoc_path_full2_singapore("e", """Figure 9: Simulated Pathways of the Social Value of R&D <br> Exponential of vertical axis gives economic value in units of consumption""","", [6,25])
[ ]:
plot_simulated_stoc_path_full2_singapore("LogSCGW_Plot", """Figure 9: Simulated Pathways of the Social Cost of Global Warming <br> Exponential of vertical axis gives economic value in units of consumption""","", [6,14])
[ ]:
plot_simulated_stoc_path_full2_singapore("TA", """""","Celsius Degree(α΅C)", [1,2.5])
[ ]:
plot_simulated_stoc_path_full2_singapore("distorted_tech_prob", "Figure 6: Distorted Probability of a Technology Change Jump","", [0,1])
[ ]:
plot_simulated_stoc_path_full2_singapore("distorted_damage_prob", "Figure 7: Distorted Probability of a Damage Jump","", [0,1])
[15]:
import plotly.io as pio
import plotly.offline as pyo
import pandas as pd
import numpy as np
from plotly.subplots import make_subplots
import plotly.graph_objects as go
import os
import sys
import pickle
import plotly.express as px
sys.path.append(os.path.dirname(os.getcwd()))
pyo.init_notebook_mode()
pio.templates.default = "none"
theta_list = pd.read_csv('data/model144.csv', header=None).to_numpy()[:, 0] / 1000.
gamma_3_list = np.linspace(0, 1./3, 20)
xi_list_fullaversion_low = [0.025, 0.050, 10000.]
xi_list_fullaversion_high = [0.075, 0.150, 10000.]
xi_list_uncertainty_low = [0.050]
xi_list_uncertainty_high = [0.150]
def plot_simulated_stoc_path_full2_singapore2(graph_type, graph_title, yaxis_label, graph_range):
xi_base = 100000.
psi_0 = 0.10583
psi_1 = 0.5
varrho = 1120.0
delta = 0.01
# fig = make_subplots(1, 2)
color = ["#d62728", "darkgreen", "navy", "darkorange"]
j_list = [16, 0, 2, 13, 14]
fig = go.Figure()
for abatement_cost in [0.1, 0.5]:
for rho in [0.66, 1.0, 1.5]:
if abatement_cost == 0.1:
xi_list_fullaversion = [0.050]
if abatement_cost == 0.5:
xi_list_fullaversion = [0.150]
folder = "./data_simul3/2jump_step_4.00,9.00_0.0,4.0_1.0,6.0_0.0,3.0_SS_0.2,0.1,0.1_LR_0.0025_FK_phi0_{}/".format(
abatement_cost)
i = 0
for xi in xi_list_fullaversion:
filename = "xi_a_{}_xi_k_{}_xi_c_{}_xi_j_{}_xi_d_{}_xi_g_{}_psi_0_{}_psi_1_{}_varrho_{}_rho_{}_delta_{}_" .format(
xi_base, xi, xi, xi, xi, xi, psi_0, psi_1, varrho, rho, delta)
with open(folder + filename + "model_tech1_pre_damage_UD_simulstoccompile_40direct_direct", "rb") as f:
model_tech1_pre_damage = pickle.load(f)
PathLength = 20
Years = model_tech1_pre_damage["years"][:,0]
Mat = model_tech1_pre_damage[graph_type][:, 0:PathLength]
for j in range(5):
legend_name = "Path {}".format(j+1)
j_used = j_list[j]
fig.add_trace(go.Scatter(x=Years,
y=Mat[:, j_used],
name=legend_name,
showlegend=True,
visible=True,
line=dict(width=8),
# visible=False
))
fig.update_traces(visible=False, line=dict(width=8))
i = i+1
PathLength=5
for i in range(PathLength):
fig.data[3*PathLength + i]["visible"] = True
# fig.data[3*2 + i+12]["visible"] = True
fig.data[3*PathLength + i]["showlegend"] = True
# fig.data[3*2 + 12]["showlegend"] = True
buttons = []
i = 0
for abatement_cost in [0.1, 0.5]:
for rho in [0.66, 1.0, 1.5]:
if abatement_cost == 0.1:
cost_label = "Οβ=0.1"
if abatement_cost == 0.5:
cost_label = "Οβ=0.5"
# Hide all traces
label = cost_label+r', Ο' + '= {:.2f}'.format(rho)
button = dict(method='update',
args=[
{
'visible': [False] * (2 * 3 * PathLength ),
'showlegend': [False] * (2 * 3 * PathLength ),
},
],
label=label)
# Enable the two traces we want to see
# print(button['args'][0]["visible"])
for j in range(PathLength):
button['args'][0]["visible"][PathLength*i + j] = True
button['args'][0]["showlegend"][PathLength*i + j] = True
i = i+1
# Add step to step list
buttons.append(button)
fig.update_layout(
updatemenus=[
dict(
type="dropdown",
direction="down",
buttons=buttons,
active=3,
x=0.6,
y=1.05,
pad={'r': 10, 't': 10})
],
)
fig.update_xaxes(showgrid=False, showline=True,
title="Years", range=[0, 40], linewidth=8)
fig.update_yaxes(showgrid=False,
showline=True,
range=graph_range,
title_text=yaxis_label, linewidth=8
# tickformat=".2f"
)
fig.update_layout(
# title=graph_title,
# barmode="overlay",
plot_bgcolor="white",
width=1100,
height=700,
font=dict(size=24),
margin=dict(l=100, r=0,t=0))
return fig
[16]:
plot_simulated_stoc_path_full2_singapore2("RD_Plot", "","Percentage (%)", [0,8])
[17]:
plot_simulated_stoc_path_full2_singapore2("e", """""","Gigatonne", [6,22])
[18]:
plot_simulated_stoc_path_full2_singapore2("TA", """""","Celsius Degree(α΅C)", [1,2.5])